﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CharacterAtrr  {

    protected string m_name;
    protected string m_iconSpriteName;
    protected float m_maxHP;
    protected float m_currentHP;
    protected float m_moveSpeed;
    protected string m_audioName;
    protected string m_effectName;
    protected string m_prefabName;

    //属性的计算 用策略模式
    protected int m_level;//等级--Soldier
    protected float m_critRate;//暴击率 
    protected float m_dmgDcsValue; 
    protected AttrStrategy m_strategy;//计算血量的最大值、抵御伤害值、暴击伤害值

    public CharacterAtrr(AttrStrategy strategy,float maxHP,string name,string iconSpriteName,float moveSpeed,int level,float critRate,string prefabName)
    {
        m_strategy = strategy;
        m_maxHP = maxHP;
        m_level = level;
        m_name = name;
        m_iconSpriteName = iconSpriteName;
        m_moveSpeed = moveSpeed;
        m_critRate = critRate;
        m_prefabName = prefabName;


        m_dmgDcsValue = m_strategy.GetDfdDmgValue(m_level);
        m_currentHP = m_strategy.GetMaxHp(m_level)+m_maxHP;

    }
  
    public string AudioName { get { return m_audioName; } }
    public float CurrentHP { get { return m_currentHP; } }
    public float CritDmg { get { return m_strategy.GetAtkPlusDmgValue(m_level); } }
    public float DfdDmg { get { return m_dmgDcsValue; } }
    public string EffectName { get { return m_effectName; } }

    public void TakeDamage(float dmg)
    {
        float damage = dmg - DfdDmg;
        if (damage < 5f)
        {
            damage = 5f;
        }
        m_currentHP -= damage;

    }

}
